<script>
	import {
		getMemberByRecCode,
		bindRecommendShip
	} from 'common/api.js'
	export default {
		onLaunch: function(options) {
			// options.query.scene = 'Ozm8x19Q'
			if (options.query.scene) {
				if (uni.getStorageSync('userInfo').id) {
					getMemberByRecCode(options.query.scene).then(res => {
						if (res.success) {
							bindRecommendShip({
								userId: uni.getStorageSync('userInfo').id,
								masterId: res.result.id
							}).then(req => {
								uni.removeStorageSync('recCode');
								options = null
								this.$toast(req.message)
							})
						}
					})
				} else {
					uni.setStorageSync('recCode', options.query.scene)
					uni.showToast({
						title: '未登录，请先登录~',
						icon: 'none'
					})
					setTimeout(function() {
						uni.switchTab({
							url: '/pages/info/info'
						});
					}, 1000); // 1000毫秒 = 1秒
				}
			}
		},
		onShow: function() {},
		onHide: function() {}
	}
</script>
<style lang="scss">
	.center {
		align-items: center;
	}

	.flex {
		display: flex;
	}

	/* .kong{
		height:var(--status-bar-height);
		width:100%;
		padding-top: 50rpx;
	} */
</style>